<template>
	<view>
		
	<form @submit="formSubmit" @reset="formReset">

		<view class="content">
			<label class="lable">电炉铁水标准碳含量</label>
			<text  class="v_input" >{{dltsjtssbz.tsCbz}}</text>
		</view>
		
		<!-- <view class="content">
			<label class="lable">废钢碳含量</label>
			<text  class="v_input">{{dltsjtssbz.fgCbz}}</text>
		</view> -->
		
		<view class="content">
			<label class="lable">电炉铁水量(kg):</label>
			<input type="number" name="dltsl"  class="v_input"  placeholder="请输入" />
		</view>
		
		<view class="content">
			<label class="lable">电炉铁水碳含量(%):</label>
			<input type="number" name="scchl"  class="v_input"  placeholder="请输入" />
		</view>
		
		<view class="break-space"></view>
		<view class="content">
			<label class="lable">电炉铁水倒出量(kg):</label>
			<text class="result" :style="{ color: textColor }">{{tsdcl}}</text>
		</view>
		<view class="content">
			<label class="lable">废钢加入量(kg):</label>
			<text  class="result" :style="{ color: textColor }">{{tsdcl}}</text>
		</view>
		<button form-type="submit" class="btnself">计算</button>
	</form>
		
	</view>
</template>

<script>
	import configService from '@/common/config.service.js';
	const apiUrl = configService.apiUrl;
	export default {
		data() {
			return {
				dltsjtssbz : null,
				tsdcl : 0,
				textColor:'black'
			}
		},
		onLoad() {
			this.getJtssbz();
		},
		onShow:function(e){
			this.$verify.verify();
		},
		methods: {
			getJtssbz(){
				uni.request({
					url:apiUrl+'/jtss/list',
					header:{
						'content-type':'application/json'
					},
					method:'POST',
					data:{
						deptId:uni.getStorageSync("deptId"),
						type: 2
					},
					success: (res) => {
						if(res.statusCode === 200  &&  res.data.data.length > 0)
						{
							this.dltsjtssbz = res.data.data[0];
						}else{
							uni.showModal({
							    title: '提示',  //提示标题
							    content: '请维护电炉铁水降碳速算标准！',  //提示内容
							    showCancel: true, //是否显示取消按钮
							    success: function (res) {
							        if (res.confirm) {  //confirm为ture，代表用户点击确定
							            console.log('点击了确定按钮');
							        } else if (res.cancel) {  //cancel为ture，代表用户点击取消
							            console.log('点击了取消按钮');
							        }
							    }
							})
						}
					}
				})
			},
			formSubmit(e) {
				
				var _this = this;
				if(_this.dltsjtssbz == null){
					uni.showToast({
						title: "请维护电炉铁水降碳速算标准！",
						icon:'error',
						duration:1000
					});
					return ;
				}
				let formData = e.detail.value;
				// 标准碳含量
				let bzchl = formData.dltsl*this.dltsjtssbz.tsCbz;
				// 现有碳含量
				let xythl = formData.dltsl*formData.scchl;
				// 废钢理论加入量
				this.tsdcl = ((xythl-bzchl)/(formData.scchl - this.dltsjtssbz.fgCbz)).toFixed(0);
				this.textColor = '#3E60D2';	
						
			}
		}
	}
</script>

<style>
@import "@/common/susuanqt.css";

</style>
